" =============== Vundle Initialization ===============
if has('vim_starting')
    set runtimepath+=~/.vim/bundle/Vundle.vim/
endif
call vundle#rc()
Plugin 'gmarik/Vundle.vim'
Plugin 'L9'
Plugin 'tpope/vim-sensible'

" Theme
Plugin 'tomasr/molokai'
let g:molokai_original = 1
colorscheme molokai

" Ruby & Rails
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rails'
" ~/.vim/macros/rails.vim
Plugin 'tpope/vim-rsi' "readline key binding

" Golang
Plugin 'fatih/vim-go'
let g:go_auto_type_info = 0
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
let g:go_fmt_command='goimports'
au FileType go nmap <LocalLeader>d <Plug>(go-doc-vertical)
au FileType go nmap <LocalLeader>i <Plug>(go-info)
au FileType go nmap <LocalLeader>r <Plug>(go-run)
au FileType go nmap <LocalLeader>b <Plug>(go-build)
au FileType go nmap <LocalLeader>t <Plug>(go-test)

Plugin 'AndrewRadev/splitjoin.vim'
" SplitjoinSplit, SplitjoinJoin

Plugin 'tpope/vim-characterize'
" ga -> to print characterize
" :help digraph-table

Plugin 'terryma/vim-multiple-cursors'
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
Plugin 'terryma/vim-expand-region'
" + to expand, - to shrink

Plugin 'AndrewRadev/inline_edit.vim'
" :InlineEdit

" Plugin 'benekastah/neomake'
" let g:neomake_open_list=0
" let g:neomake_serialize=1
" let g:neomake_serialize_abort_on_error=1
" let g:neomake_verbose=1
" let g:neomake_go_enabled_makers = ['go']

Plugin 'scrooloose/syntastic'
let g:syntastic_auto_jump=1
let g:syntastic_check_on_open = 0
let g:syntastic_always_populate_loc_list = 1
map <Leader>n :lnext<CR>
map <Leader>p :lprevious<CR>

Plugin 'Chiel92/vim-autoformat'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TMUX
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plugin 'tpope/vim-dispatch'
" Dispatch, Dispatch! (run in the background), Copen (view outputs from background job)

Plugin 'tpope/vim-tbone'
" Tmux, Twrite (write to buffer), Tyank (copy to tmux paste buffer), Tput (paste from tmux paste buffer)

" Send command from vim to a running tmux session
Plugin 'benmills/vimux'
" Prompt for a command to run
map <Leader>tp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
map <Leader>tl :VimuxRunLastCommand<CR>
" Inspect runner pane
map <Leader>ti :VimuxInspectRunner<CR>
" Close all other tmux panes in current window
map <Leader>tx :VimuxClosePanes<CR>
" Close vim tmux runner opened by VimuxRunCommand
map <Leader>tq :VimuxCloseRunner<CR>
" Interrupt any command running in the runner pane
map <Leader>ts :VimuxInterruptRunner<CR>
let g:VimuxHeight = "25"

Plugin 'jgdavey/vim-turbux'
let g:no_turbux_mappings = 1
let g:turbux_runner  = 'vimux'
autocmd FileType ruby map <Leader>tr <Plug>SendFocusedTestToTmux
autocmd FileType ruby map <Leader>tR <Plug>SendTestToTmux

Plugin 'benmills/vimux-golang'
autocmd FileType go map <Leader>tr :GolangTestCurrentPackage<CR>

Plugin 'jade.vim'
Plugin 'tpope/vim-ragtag'
" <C-X>= <C-X>+ <C-X>- <C-X>_ <C-X>' <C-X>" <C-X><Space> <C-X><CR> <C-X>/ <C-X>! <C-X>@ <C-X># <C-X>$
Plugin 'tpope/vim-eunuch'
" :Unlink :Remove :Rename :SudoWrite :W
Plugin 'tpope/vim-unimpaired'
" ]f, [f, ]n, [n
" ]e, [e               Exchange the current line with lines above/below it
" ]<Space>, [<Spance>  Add [count] blank lines above/below the cursor.
" `[x` XML encode, `]x` XML decode, `[u` URL encode, `]u` URL decode, `[y` C String encode, `]y` C String decode

let g:surround_{char2nr('-')} = "<% \r %>"
let g:surround_{char2nr('=')} = "<%= \r %>"
let g:surround_{char2nr('8')} = "/* \r */"
let g:surround_{char2nr('s')} = " \r"
let g:surround_{char2nr('^')} = "/^\r$/"
let g:surround_indent = 1
Plugin 'tpope/vim-surround'
" cs'<q>, cst", dst, ys2w), yss), v<move>S)

Plugin 'tpope/vim-abolish'
" :Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or}  {despe,sepa}rat{}
" :%Subvert/facilit{y,ies}/building{,s}/g

" GIT
Plugin 'tpope/vim-git'
Plugin 'tpope/vim-fugitive'
Plugin 'int3/vim-extradite'
Plugin 'gregsexton/gitv'
Plugin 'tpope/vim-rhubarb'
autocmd FileType gitcommit nmap <buffer> U :Git checkout -- <C-r><C-g><CR>
" ~/.vim/bundle/vim-fugitive/doc/fugitive.txt
map <LocalLeader>gs :Gstatus<CR>
map <LocalLeader>gb :Gblame<CR>
map <LocalLeader>gd :Git! diff %<CR>
map <LocalLeader>gD :Git! diff<CR>
map <LocalLeader>gc :Gcommit<CR>
map <LocalLeader>gl :Extradite<CR>
map <LocalLeader>gv :Gitv<CR>

Plugin 'airblade/vim-gitgutter'
let g:gitgutter_map_keys = 1
nmap <LocalLeader>] <Plug>GitGutterNextHunk
nmap <LocalLeader>[ <Plug>GitGutterPrevHunk
nmap <LocalLeader>v <Plug>GitGutterPreviewHunk

Plugin 'VisIncr'
Plugin 'Align'

Plugin 'tComment'
" ~/.vim/bundle/tComment/doc/tcomment.txt

Plugin 'rking/ag.vim'
" let g:ackprg = 'ag --nogroup --nocolor --column' " the_silver_searcher
nmap <Leader>a :Ag <C-R><C-W>
" copy visual value to register 'z' first
vmap <Leader>a "zy:Ag <C-R>z
" o (open) go (preview open) t (tab) T (new tab silently) v (vertical) gv q (close)


Plugin 'Valloric/YouCompleteMe'

" Snippet
Plugin 'honza/vim-snippets'
Plugin 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger="<C-j>"
let g:UltiSnipsEditSplit="vertical"

" Maintains a history of yanks
Plugin 'YankRing.vim'
let g:yankring_replace_n_pkey = '<Nop>'
let g:yankring_history_dir = '~/.cache/vim'
map <LocalLeader>p :YRShow<CR>
" s search, also have value in clipboard

Plugin 'Raimondi/delimitMate'
" automatic closing of quotes, parenthesis, brackets

" Syntax Support
Plugin 'juvenn/mustache.vim'
Plugin 'kchmck/vim-coffee-script'
Plugin 'pangloss/vim-javascript'
Plugin 'tpope/vim-markdown'
Plugin 'nono/jquery.vim'

" Preview:
" markdown (gem: bluecloth), rdoc (gem: github-markup), textile (gem: RedCloth)
" ronn (gem: ronn), html, reStructuredText (gem: RbST) and (util: rst2html)
let g:PreviewBrowsers='firefox,chromium'
Plugin 'greyblake/vim-preview'
let g:instant_markdown_autostart = 0
Plugin 'suan/vim-instant-markdown'

" Plugin 'css_color.vim'
" Plugin 'skammer/vim-css-color'
" let g:cssColorVimDoNotMessMyUpdatetime = 0
Plugin 'KabbAmine/vCoolor.vim'
" :VCoolor (Color Picker)
Plugin 'thinca/vim-quickrun'
" :QuickRun ruby / :QuickRun

Plugin 'spiiph/vim-space'
" smart <Space>

Plugin 'Lokaltog/vim-easymotion'
let g:EasyMotion_smartcase = 1
nmap <M-Space> <Plug>(easymotion-jumptoanywhere)
nmap <Space><Space> <Plug>(easymotion-s)

Plugin 'mbbill/undotree'
let g:undotree_SplitWidth = 40
let g:undotree_DiffpanelHeight = 20
let g:undotree_SetFocusWhenToggle = 1
function g:Undotree_CustomMap()
    map <buffer> n J
    map <buffer> p K
endfunction
map <LocalLeader>u :UndotreeToggle<CR>

Plugin 'Yggdroot/indentLine'
let g:indentLine_enabled=0
" map <F7> :IndentGuidesToggle <CR>

Plugin 'bling/vim-airline'
let g:airline_theme='bubblegum'
let g:airline_detect_modified=1
let g:airline_detect_paste=1
let g:airline#extensions#hunks#enabled = 1

Plugin 'bronson/vim-visual-star-search'
Plugin 'gregsexton/MatchTag'

Plugin 'majutsushi/tagbar'
" nmap <F8> :TagbarToggle<CR>
Plugin 'AutoTag'

Plugin 'ctrlpvim/ctrlp.vim'
let g:ctrlp_extensions = ['changes', 'line', 'tag', 'buffertag']
let g:ctrlp_lazy_update = 1
let g:ctrlp_max_files = 20000
let g:ctrlp_max_depth = 20
let g:ctrlp_use_caching = 1
let g:ctrlp_show_hidden = 1
let g:ctrlp_clear_cache_on_exit = 1
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
let g:ctrlp_mruf_last_entered = 1
let g:ctrlp_follow_symlinks = 1
let g:ctrlp_max_height = 35
let g:ctrlp_match_window_reversed = 0
let g:ctrlp_working_path_mode = 'w'
let g:ctrlp_custom_ignore = {
            \ 'dir':  '\v[\/](public\/system|node_modules|tmp|target|dist)|(\.(swp|ico|git|svn|hg))$',
            \ 'file': '\.jpg$\|\.png$\|\.gif$\|tags$'
            \ }

Plugin 'JazzCore/ctrlp-cmatcher'
let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }

let g:ctrlp_prompt_mappings = {
      \ 'PrtSelectMove("j")':   ['<c-n>'],
      \ 'PrtSelectMove("k")':   ['<c-p>'],
      \ 'PrtHistory(-1)':       ['<c-j>'],
      \ 'PrtHistory(1)':        ['<c-k>']
      \}

let g:ctrlp_cmd = 'CtrlP'
map <Leader>b :CtrlPBuffer<CR>
map <Leader>r :CtrlPMRUFiles<CR>
map <Leader>gr :CtrlPRoot<CR>
map <Leader>gf :CtrlPCurFile<CR>
map <Leader>gl :CtrlPLine<CR>
map <Leader>gt :CtrlPTag<CR>
map <Leader>gb :CtrlPBufTag<CR>
map <Leader>gq :CtrlPQuickfix<CR>
map <Leader>gc :CtrlPChange<CR>
map <Leader>gC :CtrlPChangeAll<CR>
map <Leader>gm :CtrlPMixed<CR>
map <Leader>gp :CtrlPRTS<CR>
let g:ctrlp_buftag_types = {
            \ 'go'     : '--language-force=go',
            \ 'css'     : '--language-force=css',
            \ 'scss'     : '--language-force=scss',
            \ 'js'     : '--language-force=js',
            \ 'coffee'     : '--language-force=coffee',
            \ 'markdown'     : '--language-force=markdown'
            \ }

Plugin 'gmarik/github-search.vim'
" :GHSearchRepo something

" vim:tw=77:sw=4:ts=8:et:fdm=marker:ft=vim:norl:
